#include "playwindow.h"
#include "ui_playwindow.h"
#include <QMediaPlayer>

playWindow::playWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::playWindow)
{
    ui->setupUi(this);
//    setAttribute(Qt::WA_TranslucentBackground);
    QString url = "../AllVideo/1.1.mp4";
    ui->playWidget->setUrl(url);
    ui->playWidget->open();

//    // 视频播放结束信号
//    connect(player, &QMediaPlayer::stateChanged, [=](QMediaPlayer::State state) {
//        if (state == QMediaPlayer::StoppedState) {
//            qDebug() << "Media playback finished!";
//            ui->playWidget->close();
//        }
//    });

}

playWindow::~playWindow()
{
    delete ui;
}

void playWindow::keyPressEvent(QKeyEvent *event){
    if (event->key() == Qt::Key_Escape) {
        showNormal();
    }
}

void playWindow::mouseDoubleClickEvent(QMouseEvent *event){
    if (event->button() == Qt::LeftButton) {
        if (isFullScreen()) {
            showNormal();
        } else {
            showFullScreen();
        }
    }
}
